package com.example.module_word.data;



import com.example.module_word.room.DanCiDao;
import com.example.module_word.room.DanCiDataBase;
import com.example.module_word.room.Danci;
import com.example.module_word.room.entity.JiHua;
import com.example.module_word.room.entity.MyStack;
import com.example.module_word.room.entity.MyWord;

import java.util.List;

public class DanCiData {
    public static DanCiDao danCiDao = DanCiDataBase.getInstance().getDanCiDao();
    public static List<String> danCiKindList;
    //获取单词种类
    public static List<String> getDanCiKindList(){
        if (danCiKindList==null){
            danCiKindList = danCiDao.queryWorkKind();
        }
        return danCiKindList;
    }
    //获取某种类的数量
    public static Long getCountByKind(String kind){
        return danCiDao.queryCountByKind(kind);
    }
    //根据种类获取单词
    public static List<Danci> getDanCiByKind(String kind){
        return danCiDao.queryDanCiByKind(kind);
    }

    //保存到我的书库
    public static void insertMyStack(String kind,boolean flag){
        danCiDao.insertMyStack(new MyStack(kind,flag));
    }
    //从我的书库中删除
    public static void deleteMyStackByKind(String kind){
        danCiDao.deleteMyStackByKind(kind);
    }
    public static List<String> getMyStack(){
        return danCiDao.queryMyStack();
    }
    //查询我的书库的值
    public static boolean isMyStackByKind(String kind){
        return danCiDao.queryMyStackByKind(kind).size()!=0;
    }
    public static void updateMyStackByKind(boolean isSelect,String kind){
        danCiDao.updateMyStackByKind(isSelect,kind);
    }
    //查询被选中的kind
    public static String getMyStackByFlag(){
        return danCiDao.queryMyStackByFlag(true);
    }
    //新增计划
    public static void insertJiHua(List<JiHua> list){
        danCiDao.insertJiHua(list);
    }
    public static void insertJiHua(JiHua jiHua){
        danCiDao.insertJiHua(jiHua);
    }
    //修改计划
    public static void updateJiHua(String kind,Long start_time,Long end_time){
        danCiDao.updateJiHua(start_time,end_time,kind);
    }
    //修改计划的签到次数
    public static void updateJiHuaDayByKind(String kind){
        danCiDao.updateJiHuaDayByKind(danCiDao.queryJiHuaByKind(kind).get(0).day+1,kind);
    }

    //查询计划
    public static List<JiHua> getJiHuaList(String kind){
        return danCiDao.queryJiHuaByKind(kind);
    }
    //查询被选中的kind
    public static String getJiHuaByIsSelect(){
        return danCiDao.queryJiHuaByIsSelect(true);
    }

    //新增单词
    public static void insertMyWord(MyWord myWord){
        danCiDao.insertMyWord(myWord);
    }
    //查询单词是否存在
    public static boolean isMyWord(String word){
        return danCiDao.queryMyWordByWord(word).size()==0?false:true;
    }
    //查询所有我的单词
    public static List<MyWord> getMyWord(){
        return danCiDao.queryMyWord();
    }
    //查询该书的进度
    public static int getMyWordCountByKind(String kind){
        return danCiDao.queryMyWordCountByKind(kind);
    }
}
